package com.twu.biblioteca.util;

import java.io.*;
import java.util.Properties;

/**
 * Created by madhu on 1/5/14.
 */
public class UserDetails {

    private Properties details;

    public UserDetails(String fileName) {
        details = new Properties();
        loadDetails(fileName);
    }

    private void loadDetails(String fileName) {

        InputStream inputStream = null;

        try {
            inputStream = new FileInputStream(fileName);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

        try {
            details.load(inputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }

        if(inputStream!=null) {
            try {
                inputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }

    public String getUserDetails(String libraryNumber) {
        return details.getProperty(libraryNumber);
    }

}
